package vip.idiy.anwei_android_iot.adapters;


import android.view.View;
import android.view.ViewGroup;

import androidx.viewpager.widget.PagerAdapter;

import java.io.Serializable;
import java.util.List;

/**
 * 页面Adapter
 */
public class MyViewPageAdapter extends PagerAdapter implements Serializable {
    private String TAG = "myTag " + " MyViewPageAdapter ";
    private List<View> views;

    public MyViewPageAdapter(List<View> views) {
        this.views = views;
    }

    @Override
    public int getCount() {
        return views.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }



    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position), 0);
        return views.get(position);
    }
}